package selfview.sufutian.com.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.RelativeLayout;

import java.util.Random;

import selfview.sufutian.com.myapplication.draw2d.BitmapDraw;

/**
 * Created by sufutian on 2017/2/6.
 */

public class BitmapDrawActivity extends Activity{


    public static void toActivity(Activity activity) {
        Intent intent = new Intent(activity, BitmapDrawActivity.class);
        activity.startActivity(intent);

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_bitmapdraw);
        final BitmapDraw bitmapDraw=new BitmapDraw(BitmapDrawActivity.this);
        setContentView(bitmapDraw,new RelativeLayout.LayoutParams(-1,-1));

        bitmapDraw.startTranslate();
        bitmapDraw.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Random random = new Random();
                int startLeft = random.nextInt(200);
                int startTop = random.nextInt(250);
                int toLeft = random.nextInt(550) + 200;
                int toBottom = random.nextInt(1000) + 250;
                bitmapDraw.startTranslate(startLeft, startTop, toLeft, toBottom, 1000);
                return true;
            }
        });


    }
}
